SchoolProduct   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 52
dl 0
loc 61
rs 10
c 0
b 0
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A updatePrices 0 4 1
A getId 0 3 1
A getPhotographerUnitPrice 0 3 1
A getSchool 0 3 1
A getParentUnitPrice 0 3 1
A getProduct 0 3 1
A getParentPriceFromCents 0 3 1
A getPhotographerPriceFromCents 0 3 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { Product } from '../Product/Product.entity';
3
import { School } from './School.entity';
4
5
@Entity()
6
export class SchoolProduct {
7
  @PrimaryGeneratedColumn('uuid')
8
  private id: string;
9
10
  @Column({ type: 'integer', nullable: false, default: 0 })
11
  private parentUnitPrice: number;
12
13
  @Column({ type: 'integer', nullable: false, default: 0 })
14
  private photographerUnitPrice: number;
15
16
  @ManyToOne(() => School, { nullable: false, onDelete: 'CASCADE' })
17
  private school: School;
18
19
  @ManyToOne(() => Product, { nullable: true, onDelete: 'CASCADE' })
20
  private product: Product;
21
22
  constructor(
23
    parentUnitPrice: number,
24
    photographerUnitPrice: number,
25
    school: School,
26
    product: Product
27
  ) {
28
    this.parentUnitPrice = parentUnitPrice;
29
    this.photographerUnitPrice = photographerUnitPrice;
30
    this.school = school;
31
    this.product = product;
32
  }
33
34
  public updatePrices(parentUnitPrice: number, photographerUnitPrice: number): void {
35
    this.parentUnitPrice = parentUnitPrice;
36
    this.photographerUnitPrice = photographerUnitPrice;
37
  }
38
39
  public getId(): string {
40
    return this.id;
41
  }
42
43
  public getPhotographerUnitPrice(): number {
44
    return this.photographerUnitPrice;
45
  }
46
47
  public getPhotographerPriceFromCents(): number {
48
    return this.photographerUnitPrice / 100;
49
  }
50
51
  public getParentUnitPrice(): number {
52
    return this.parentUnitPrice;
53
  }
54
55
  public getParentPriceFromCents(): number {
56
    return this.parentUnitPrice / 100;
57
  }
58
59
  public getSchool(): School {
60
    return this.school;
61
  }
62
63
  public getProduct(): Product {
64
    return this.product;
65
  }
66
}
67